package com.wkbb.sports.model;

import com.wkbb.common.dto.basic.UserDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author lbh
 * @date 2021年03月29日 17:58:34
 * @description: hlife_work_student  作业记录表
 */
@Data
public class HlifeWorkStudent extends BaseEntity{

    @ApiModelProperty(value = "作业ID")
    private Long workId;

    @ApiModelProperty(value = "项目ID")
    private byte projectId;

    @ApiModelProperty(value = "学校ID")
    private Long orgId;

    @ApiModelProperty(value = "年级ID")
    private Long gradeId;

    @ApiModelProperty(value = "年级名称")
    private String gradeName;

    @ApiModelProperty(value = "班级ID")
    private Long classId;

    @ApiModelProperty(value = "学生头像地址")
    private String headImgUrl;

    @ApiModelProperty(value = "班级名称")
    private String className;

    @ApiModelProperty(value = "学生ID")
    private Long studentId;

    @ApiModelProperty(value = "学生名称")
    private String studentName;

    @ApiModelProperty(value = "性别(1男/2女)")
    private byte sex;

    @ApiModelProperty(value = "成绩")
    private Double achivement;

    @ApiModelProperty(value = "得分")
    private Double score;

    @ApiModelProperty(value = "加分项得分")
    private Double plusesScore;

    @ApiModelProperty(value = "实际时长(单位：秒)")
    private Integer actualTime;

    @ApiModelProperty(value = "状态(0未开始 1进行中2已结束3已取消)")
    private Integer status;

    @ApiModelProperty(value = "是否达标(0未达标/1已达标)")
    private Integer reached;

    @ApiModelProperty(value = "工号或学号")
    private String userNo;

    @ApiModelProperty(value = "模式(1模拟考试 2限时限数 3数量模式 4时间模式)")
    private Integer modelType;

    //==================dto字段===不对应数据库表任何字段========================================
    @ApiModelProperty(value = "实际时长(单位：分.秒)")
    private String actualSecAndMinTime;

    @ApiModelProperty(value = "速度")
    private double speed;

    @ApiModelProperty(value = "排名编号")
    private int no;

    public static HlifeWorkStudent generateHlifeWorkStudentFromHistoryDto(HlifeWorkStudentHistory hlifeWorkStudentHistory1,HlifeWorkStudentHistory hlifeWorkStudentHistoryOptimal, UserDto userDto){
        HlifeWorkStudent hlifeWorkStudent=new HlifeWorkStudent();
        hlifeWorkStudent.setProjectId(hlifeWorkStudentHistoryOptimal.getProjectId());
        hlifeWorkStudent.setOrgId(hlifeWorkStudentHistoryOptimal.getOrgId());
        hlifeWorkStudent.setGradeId(hlifeWorkStudentHistoryOptimal.getGradeId());
        hlifeWorkStudent.setGradeName(hlifeWorkStudentHistoryOptimal.getGradeName());
        hlifeWorkStudent.setClassId(hlifeWorkStudentHistoryOptimal.getClassId());
        hlifeWorkStudent.setClassName(hlifeWorkStudentHistoryOptimal.getClassName());
        hlifeWorkStudent.setStudentId(hlifeWorkStudentHistoryOptimal.getStudentId());
        hlifeWorkStudent.setStudentName(hlifeWorkStudentHistoryOptimal.getStudentName());
        hlifeWorkStudent.setSex(hlifeWorkStudentHistoryOptimal.getSex());
        hlifeWorkStudent.setAchivement(hlifeWorkStudentHistoryOptimal.getAchivement());
        hlifeWorkStudent.setScore(hlifeWorkStudentHistoryOptimal.getScore());
        hlifeWorkStudent.setPlusesScore(hlifeWorkStudentHistoryOptimal.getPlusesScore());
        hlifeWorkStudent.setActualTime(hlifeWorkStudentHistoryOptimal.getActualTime());
        hlifeWorkStudent.setReached(hlifeWorkStudentHistoryOptimal.getReached());
        hlifeWorkStudent.setUserNo(hlifeWorkStudentHistoryOptimal.getUserNo());

        hlifeWorkStudent.setModelType(hlifeWorkStudentHistoryOptimal.getModelType());
        if(hlifeWorkStudent.getModelType() == null){
            hlifeWorkStudent.setModelType(4);//给默认值:4时间模式
        }

        hlifeWorkStudent.setId(hlifeWorkStudentHistory1.getWorkStudentId());
        hlifeWorkStudent.setWorkId(hlifeWorkStudentHistory1.getWorkId());
        hlifeWorkStudent.setStatus(1);
        hlifeWorkStudent.setUpdateBy(userDto.getName());
        //hlifeWorkStudent.setUpdateTime(new Date());
        hlifeWorkStudent.setUpdateTime(hlifeWorkStudentHistoryOptimal.getUpdateTime());
        hlifeWorkStudent.setHeadImgUrl(userDto.getHeadImgUrl());

        return hlifeWorkStudent;

    }


}
